package com.auotc.demo

import android.content.Context
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.fragment_vp.*

/**
 * Created by lgs on 2019/4/29.
 */
class VpFragment : Fragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.fragment_vp, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
    }

    private fun initView() {

        recyclerView.layoutManager = LinearLayoutManager(context)
        recyclerView.addItemDecoration(DividerItemDecoration(context, LinearLayoutManager.VERTICAL))
        recyclerView.adapter = MyAdapter(context!!)

    }

    inner class MyAdapter(context: Context) : RecyclerView.Adapter<MyAdapter.ViewHolder>() {

        private val mInflater: LayoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater

        override fun onCreateViewHolder(p0: ViewGroup, p1: Int): ViewHolder {
            return ViewHolder(mInflater.inflate(R.layout.adapter_my, p0, false))
        }

        override fun getItemCount() = 20

        override fun onBindViewHolder(p0: ViewHolder, p1: Int) {

        }

        inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
    }

}